package errors

import (
	"github.com/micro/go-micro/v2/errors"
)

var (
	Ignore                    = &errors.Error{Id: "", Detail: "member error", Code: -33000}
	ServerError               = &errors.Error{Id: "", Detail: "server error", Code: -32000}
	ParamError                = &errors.Error{Id: "", Detail: "param error", Code: -32001}
	TokenError                = &errors.Error{Id: "", Detail: "token error", Code: -32002}
	ItemNotEnoughError        = &errors.Error{Id: "", Detail: "item not enough", Code: -32003}
	CoinNotEnoughError        = &errors.Error{Id: "", Detail: "coin not enough", Code: -32004}
	GoldNotEnoughError        = &errors.Error{Id: "", Detail: "gold not enough", Code: -32005}
	DiamondNotEnoughError     = &errors.Error{Id: "", Detail: "diamond not enough", Code: -32006}
	PositionNoPermissionError = &errors.Error{Id: "", Detail: "position no permission", Code: -32007}
	MemberError               = &errors.Error{Id: "", Detail: "member error", Code: -32008}

	//LevelNotEnoughError  = errors.Error{id:"",  "",  10000, "LevelNotEnough")}
	//ExpNotEnoughError    = errors.Error{id:"",  "",  10000, "ExpNotEnough")}
	//LevelAlreadyMaxError = errors.Error{id:"",  "",  10000, "LevelAlreadyMax")}
	//ClassAlreadyMaxError = errors.Error{id:"",  "",  10000, "ClassAlreadyMax")}
	//NoUnlockError        = errors.Error{id:"",  "",  10000, "NoUnlock")}
	//AlreadyReceiveError       = errors.Error{id:"AlreadyReceive")
	//NumberNotEnoughError      = errors.Error{id:"",  "",  10000, "NumberNotEnough")}
	//VIPNotEnoughError         = errors.Error{id:"",  "",  10000, "VIPNotEnough")}

)

func New(str string) error {
	return &errors.Error{Id: "", Detail: str, Code: -32000}
}

//func Error{id:text string) error {
//	return errors.Error{id:text)
//}
//
func Parse(err error) *errors.Error {

	switch err.(type) {
	case *errors.Error:

		return err.(*errors.Error)

	default:

		err2 := errors.Parse(err.Error())
		err2.Code = -32000
		return err2
	}
}
